package com.haibo.test.utils;

import com.alibaba.fastjson.JSONObject;
import com.haibo.test.model.dto.JsonVCode;
import com.wxapi.WxApiCall.WxApiCall;
import com.wxapi.model.RequestModel;

import java.util.HashMap;
import java.util.Map;

/**
 * @author XD
 * @date 2019/6/28 16:22
 */
public class WxApiCallUtils {
    public static String Vcode(String dataStr){
        RequestModel model = new RequestModel();
        model.setGwUrl("https://way.jd.com/showapi/checkcode_math");
        //算术图片验证码识别appKey
        model.setAppkey("a85fb40afdcacae0db0e84514166091a");
        model.setBodyStr("img_base64="+dataStr);
        Map queryMap = new HashMap();
        model.setQueryParams(queryMap);
        WxApiCall call = new WxApiCall();
        call.setModel(model);
        call.request();
        String result=call.request();
        if(null!=result&&!result.isEmpty()) {
            JSONObject jsStr = JSONObject.parseObject(result);
            JsonVCode jsonVCode = JSONObject.toJavaObject(jsStr, JsonVCode.class);
            return jsonVCode.getResult().getShowapi_res_body().getResult();
        }
        return null;
    }
}
